<?php  include VIEWPATH.'common/head.php';  ?>
<script type="text/javascript">
    function sel_post_list(){
        var post_add_time = $("#post_add_time").val();
        var url = "index.php?c=index&m=post_list_data";
        var param = {"add_time":post_add_time};
        common_ajax(url, param, function(data){
            if(data.errorCode == 0) {
                var html = data.responseData;
                $("#post_data_list").html(html);
                return true;
            }else{
                alert(data.errorMsg);
            }
        });
    }
    function sel_reply_list(){
        var reply_add_time = $("#reply_add_time").val();
        var url = "index.php?c=index&m=rely_list_data";
        var param = {"add_time":reply_add_time};
        common_ajax(url, param, function(data){
            if(data.errorCode == 0) {
                var html = data.responseData;
                $("#rely_data_list").html(html);
                return true;
            }else{
                alert(data.errorMsg);
            }
        });
    }
    function sel_user_list(){
        var user_add_time = $("#user_add_time").val();
        var url = "index.php?c=index&m=user_list_data";
        var param = {"add_time":user_add_time};
        common_ajax(url, param, function(data){
            if(data.errorCode == 0) {
                var html = data.responseData;
                $("#user_data_list").html(html);
                return true;
            }else{
                alert(data.errorMsg);
            }
        });
    }
</script>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="row">
                <div class="col-sm-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>主贴数据</h5>
                            <div class="ibox-tools">
                                <a class="collapse-link">
                                    <i class="fa fa-chevron-up"></i>
                                </a>
                                <a class="close-link">
                                    <i class="fa fa-times"></i>
                                </a>
                            </div>
                        </div>
                        <div class="ibox-content">
                            <form class="form-horizontal" action="index.php?c=<?php echo $_REQUEST['c'];?>&m=<?php echo $_REQUEST['m'];?>" name="form" method="post">
                                <div class="form-group">
                                    <div class="col-sm-1 text-right"><label class="control-label">时段：</label></div>
                                    <div class="col-sm-2">
                                        <select id="post_add_time" name="add_time" class="form-control">
                                            <option value="-7">最近7天</option>
                                            <option value="-14">最近14天</option>
                                            <option value="-30">最近30天</option>
                                        </select>
                                    </div>
                                    <div class="col-sm-1">
                                        <button class="btn btn-sm btn-primary" type="button" onclick="sel_post_list()"> 搜索 </button>
                                    </div>
                                </div>
                                <table class="table table-bordered table-hover">
                                    <thead>
                                        <tr>
                                            <th>日期</th>
                                            <th>新增主贴</th>
                                            <th>被审核数量</th>
                                            <th>已通过数量</th>
                                            <th>被打回数量</th>
                                            <th>被删除数量</th>
                                            <th>精华帖</th>
                                            <th>精华率</th>
                                            <th>低质贴占比</th>
                                        </tr>
                                    </thead>
                                    <tbody id="post_data_list">
                                        <?php
                                        $j_addNumTotal = 0;$j_auditNumTotal=0;$j_tongNumTotal=0;$j_weiNumTotal=0;$j_delNumTotal=0;$j_hotNumTotal=0;
                                        $z_addNumTotal = 0;$z_auditNumTotal=0;$z_tongNumTotal=0;$z_weiNumTotal=0;$z_delNumTotal=0;$z_hotNumTotal=0;
                                        foreach($postDayList as $postDay){
                                            $startTime = strtotime($postDay["add_time"]." 00:00:00");
                                            $endTime = strtotime($postDay["add_time"]." 23:59:59");

                                            $j_addParam = array("startTime"=>$startTime, "endTime"=>$endTime, "source_type"=>1);
                                            $j_addNum = $this->IndexModel->tongjiPostNum($j_addParam);//机器人
                                            $j_addNumTotal += $j_addNum;

                                            $z_addParam = array("startTime"=>$startTime, "endTime"=>$endTime, "source_type"=>2);
                                            $z_addNum = $this->IndexModel->tongjiPostNum($z_addParam);//注册用户
                                            $z_addNumTotal += $z_addNum;

                                            $j_auditParam  = array("startTime"=>$startTime, "endTime"=>$endTime, "is_audit" => 1, "source_type"=>1);
                                            $j_auditNum  = $this->IndexModel->tongjiPostNum($j_auditParam);//机器人
                                            $j_auditNumTotal+=$j_auditNum;

                                            $z_auditParam  = array("startTime"=>$startTime, "endTime"=>$endTime, "is_audit" => 1, "source_type"=>2);
                                            $z_auditNum  = $this->IndexModel->tongjiPostNum($z_auditParam);//注册用户
                                            $z_auditNumTotal+=$z_auditNum;

                                            $j_tongParam  = array("startTime"=>$startTime, "endTime"=>$endTime, "status" => 1, "source_type"=>1);
                                            $j_tongNum = $this->IndexModel->tongjiPostNum($j_tongParam);//机器人
                                            $j_tongNumTotal+=$j_tongNum;

                                            $z_tongParam  = array("startTime"=>$startTime, "endTime"=>$endTime, "status" => 1, "source_type"=>2);
                                            $z_tongNum = $this->IndexModel->tongjiPostNum($z_tongParam);//注册用户
                                            $z_tongNumTotal+=$z_tongNum;

                                            $j_weiParam  = array("startTime"=>$startTime, "endTime"=>$endTime, "status" => 2,  "source_type"=>1);
                                            $j_weiNum  = $this->IndexModel->tongjiPostNum($j_weiParam);//机器人
                                            $j_weiNumTotal+=$j_weiNum;

                                            $z_weiParam  = array("startTime"=>$startTime, "endTime"=>$endTime, "status" => 2,  "source_type"=>2);
                                            $z_weiNum  = $this->IndexModel->tongjiPostNum($z_weiParam);//注册用户
                                            $z_weiNumTotal+=$z_weiNum;

                                            $j_delParam = array("startTime"=>$startTime, "endTime"=>$endTime, "status" => 3,  "source_type"=>1);
                                            $j_delNum  = $this->IndexModel->tongjiPostNum($j_delParam);//机器人
                                            $j_delNumTotal+=$j_delNum;

                                            $z_delParam = array("startTime"=>$startTime, "endTime"=>$endTime, "status" => 3,  "source_type"=>2);
                                            $z_delNum  = $this->IndexModel->tongjiPostNum($z_delParam);//注册用户
                                            $z_delNumTotal+=$z_delNum;

                                            $j_hotParam = array("startTime"=>$startTime, "endTime"=>$endTime, "is_hot" => 1, "status" => 1,  "source_type"=>1);
                                            $j_hotNum  = $this->IndexModel->tongjiPostNum($j_hotParam);//机器人
                                            $j_hotNumTotal+=$j_hotNum;

                                            $z_hotParam = array("startTime"=>$startTime, "endTime"=>$endTime, "is_hot" => 1, "status" => 1,  "source_type"=>2);
                                            $z_hotNum  = $this->IndexModel->tongjiPostNum($z_hotParam);//注册用户
                                            $z_hotNumTotal+=$z_hotNum;
                                        ?>
                                            <tr>
                                                <td><?php echo $postDay["add_time"];?></td>
                                                <td><?php echo "机器：".$j_addNum.";注册:".$z_addNum;?></td>
                                                <td><?php echo "机器：".$j_auditNum.";注册:".$z_auditNum;?></td>
                                                <td><?php echo "机器：".$j_tongNum.";注册:".$z_tongNum;?></td>
                                                <td><?php echo "机器：".$j_weiNum.";注册:".$z_weiNum;?></td>
                                                <td><?php echo "机器：".$j_delNum.";注册:".$z_delNum;?></td>
                                                <td><?php echo "机器：".$j_hotNum.";注册:".$z_hotNum;?></td>
                                                <?php
                                                    $j_d = $j_addNum > 0 ? round($j_hotNum / $j_addNum * 100,2)."%" : "0%";
                                                    $z_h = $z_addNum > 0 ? round($z_hotNum / $z_addNum * 100,2)."%" : "0%";
                                                    $j_a = $j_addNum > 0 ? round(($j_delNum + $j_weiNum)/ $j_addNum * 100,2)."%": "0%";
                                                    $z_a = $z_addNum > 0 ? round(($z_delNum + $z_weiNum)/ $z_addNum * 100,2)."%": "0%";
                                                ?>
                                                <td><?php echo "机器：".$j_d.";注册:".$z_h;?></td>
                                                <td><?php echo "机器：".$j_a.";注册:".$z_a;?></td>
                                            </tr>
                                        <?php } ?>
                                        <tr>
                                            <td>合计</td>
                                            <td><?php echo "机器：".$j_addNumTotal.";注册:".$z_addNumTotal;?></td>
                                            <td><?php echo "机器：".$j_auditNumTotal.";注册:".$z_auditNumTotal;?></td>
                                            <td><?php echo "机器：".$j_tongNumTotal.";注册:".$z_tongNumTotal;?></td>
                                            <td><?php echo "机器：".$j_weiNumTotal.";注册:".$z_weiNumTotal;?></td>
                                            <td><?php echo "机器：".$j_delNumTotal.";注册:".$z_delNumTotal;?></td>
                                            <td><?php echo "机器：".$j_hotNumTotal.";注册:".$z_hotNumTotal;?></td>
                                            <?php
                                                $j_t = $j_addNumTotal > 0 ? round($j_hotNumTotal / $j_addNumTotal * 100,2)."%" : "0%";
                                                $z_t = $z_addNumTotal > 0 ? round($z_hotNumTotal / $z_addNumTotal * 100,2)."%" : "0%";
                                                $j_d = $j_addNumTotal > 0 ? round(($j_delNumTotal + $j_weiNumTotal) / $j_addNumTotal * 100,2)."%" : "0%";
                                                $z_d = $z_addNumTotal > 0 ? round(($z_delNumTotal + $z_weiNumTotal) / $z_addNumTotal * 100,2)."%" : "0%";
                                            ?>
                                            <td><?php echo "机器：".$j_t.";注册:".$z_t;?></td>
                                            <td><?php echo "机器：".$j_d.";注册:".$z_d;?>%</td>
                                        </tr>
                                    </tbody>
                                </table>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12">
            <div class="row">
                <div class="col-sm-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>评论数据</h5>
                            <div class="ibox-tools">
                                <a class="collapse-link">
                                    <i class="fa fa-chevron-up"></i>
                                </a>
                                <a class="close-link">
                                    <i class="fa fa-times"></i>
                                </a>
                            </div>
                        </div>
                        <div class="ibox-content">
                            <form class="form-horizontal" action="index.php?c=<?php echo $_REQUEST['c'];?>&m=<?php echo $_REQUEST['m'];?>" name="form" method="post">
                                <div class="form-group">
                                    <div class="col-sm-1 text-right"><label class="control-label">时段：</label></div>
                                    <div class="col-sm-2">
                                        <select id="reply_add_time" name="reply_add_time" class="form-control">
                                            <option value="-7">最近7天</option>
                                            <option value="-14">最近14天</option>
                                            <option value="-30">最近30天</option>
                                        </select>
                                    </div>
                                    <div class="col-sm-1">
                                        <button class="btn btn-sm btn-primary" type="button" onclick="sel_reply_list()"> 搜索 </button>
                                    </div>
                                </div>
                                <table class="table table-bordered table-hover">
                                    <thead>
                                        <tr>
                                            <th>日期</th>
                                            <th>新增回复</th>
                                            <th>被审核数量</th>
                                            <th>已通过数量</th>
                                            <th>被打回数量</th>
                                            <th>被删除数量</th>
                                            <th>水评论占比</th>
                                        </tr>
                                    </thead>
                                    <tbody  id="rely_data_list">
                                        <?php
                                        $j_addNumTotal = 0;$j_auditNumTotal=0;$j_tongNumTotal=0;$j_weiNumTotal=0;$j_delNumTotal=0;
                                        $z_addNumTotal = 0;$z_auditNumTotal=0;$z_tongNumTotal=0;$z_weiNumTotal=0;$z_delNumTotal=0;
                                        foreach($replyDayList as $replyDay){
                                            $startTime = strtotime($replyDay["add_time"]." 00:00:00");
                                            $endTime = strtotime($replyDay["add_time"]." 23:59:59");

                                            $j_addParam = array("startTime"=>$startTime, "endTime"=>$endTime, "source_type"=>1);
                                            $j_addNum = $this->IndexModel->tongjiReplyNum($j_addParam);
                                            $j_addNumTotal += $j_addNum;

                                            $z_addParam = array("startTime"=>$startTime, "endTime"=>$endTime, "source_type"=>2);
                                            $z_addNum = $this->IndexModel->tongjiReplyNum($z_addParam);
                                            $z_addNumTotal += $z_addNum;

                                            $j_auditParam  = array("startTime"=>$startTime, "endTime"=>$endTime, "is_audit" => 1, "source_type"=>1);
                                            $j_auditNum  = $this->IndexModel->tongjiReplyNum($j_auditParam);
                                            $j_auditNumTotal+=$j_auditNum;

                                            $z_auditParam  = array("startTime"=>$startTime, "endTime"=>$endTime, "is_audit" => 1, "source_type"=>2);
                                            $z_auditNum  = $this->IndexModel->tongjiReplyNum($z_auditParam);
                                            $z_auditNumTotal+=$z_auditNum;

                                            $j_tongParam  = array("startTime"=>$startTime, "endTime"=>$endTime, "is_audit" => 1, "status" => 1, "source_type"=>1);
                                            $j_tongNum = $this->IndexModel->tongjiReplyNum($j_tongParam);
                                            $j_tongNumTotal+=$j_tongNum;

                                            $z_tongParam  = array("startTime"=>$startTime, "endTime"=>$endTime, "is_audit" => 1, "status" => 1, "source_type"=>2);
                                            $z_tongNum = $this->IndexModel->tongjiReplyNum($z_tongParam);
                                            $z_tongNumTotal+=$z_tongNum;

                                            $j_weiParam  = array("startTime"=>$startTime, "endTime"=>$endTime, "is_audit" => 1, "status" => 2, "source_type"=>1);
                                            $j_weiNum  = $this->IndexModel->tongjiReplyNum($j_weiParam);
                                            $j_weiNumTotal+=$j_weiNum;

                                            $z_weiParam  = array("startTime"=>$startTime, "endTime"=>$endTime, "is_audit" => 1, "status" => 2, "source_type"=>2);
                                            $z_weiNum  = $this->IndexModel->tongjiReplyNum($z_weiParam);
                                            $z_weiNumTotal+=$z_weiNum;

                                            $j_delParam = array("startTime"=>$startTime, "endTime"=>$endTime, "status" => -1, "source_type"=>1);
                                            $j_delNum  = $this->IndexModel->tongjiPostNum($j_delParam);
                                            $j_delNumTotal+=$j_delNum;

                                            $z_delParam = array("startTime"=>$startTime, "endTime"=>$endTime, "status" => -1, "source_type"=>2);
                                            $z_delNum  = $this->IndexModel->tongjiPostNum($z_delParam);
                                            $z_delNumTotal+=$z_delNum;
                                            ?>
                                            <tr>
                                                <td><?php echo $replyDay["add_time"];?></td>
                                                <td><?php echo "机器：".$j_addNum.";注册:".$z_addNum;?></td>
                                                <td><?php echo "机器：".$j_auditNum.";注册:".$z_auditNum;?></td>
                                                <td><?php echo "机器：".$j_tongNum.";注册:".$z_tongNum;?></td>
                                                <td><?php echo "机器：".$j_weiNum.";注册:".$z_weiNum;?></td>
                                                <td><?php echo "机器：".$j_delNum.";注册:".$z_delNum;?></td>
                                                <?php
                                                $j_d = $j_addNum > 0 ? round(($j_delNum + $j_weiNum) / $j_addNum * 100,2)."%" : "0%";
                                                $z_d = $z_addNum > 0 ? round(($z_delNum + $z_weiNum) / $z_addNum * 100,2)."%" : "0%";
                                                ?>
                                                <td><?php echo "机器：".$j_d.";注册:".$z_d;?></td>
                                            </tr>
                                        <?php } ?>
                                        <tr>
                                            <td>合计</td>
                                            <td><?php echo "机器：".$j_addNumTotal.";注册:".$z_addNumTotal;?></td>
                                            <td><?php echo "机器：".$j_auditNumTotal.";注册:".$z_auditNumTotal;?></td>
                                            <td><?php echo "机器：".$j_tongNumTotal.";注册:".$z_tongNumTotal;?></td>
                                            <td><?php echo "机器：".$j_weiNumTotal.";注册:".$z_weiNumTotal;?></td>
                                            <td><?php echo "机器：".$j_delNumTotal.";注册:".$z_delNumTotal;?></td>
                                            <?php
                                                $j_d  = $j_addNumTotal > 0 ? round(($j_delNumTotal + $j_weiNumTotal) / $j_addNumTotal * 100,2)."%" : "0%";
                                                $z_d = $z_addNumTotal > 0 ? round(($z_delNumTotal + $z_weiNumTotal) / $z_addNumTotal * 100,2)."%" : "0%";
                                            ?>
                                            <td><?php echo "机器：".$j_d.";注册:".$z_d;?></td>
                                        </tr>
                                    </tbody>
                                </table>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12">
            <div class="row">
                <div class="col-sm-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>用户数据</h5>
                            <div class="ibox-tools">
                                <a class="collapse-link">
                                    <i class="fa fa-chevron-up"></i>
                                </a>
                                <a class="close-link">
                                    <i class="fa fa-times"></i>
                                </a>
                            </div>
                        </div>
                        <div class="ibox-content">
                            <form class="form-horizontal" action="index.php?c=<?php echo $_REQUEST['c'];?>&m=<?php echo $_REQUEST['m'];?>" name="form" method="post">
                                <div class="form-group">
                                    <div class="col-sm-1 text-right"><label class="control-label">时段：</label></div>
                                    <div class="col-sm-2">
                                        <select id="user_add_time" name="user_add_time" class="form-control">
                                            <option value="-7">最近7天</option>
                                            <option value="-14">最近14天</option>
                                            <option value="-30">最近30天</option>
                                        </select>
                                    </div>
                                    <div class="col-sm-1">
                                        <button class="btn btn-sm btn-primary" type="button" onclick="sel_user_list()"> 搜索 </button>
                                    </div>
                                </div>
                                <table class="table table-bordered table-hover">
                                    <thead>
                                        <tr>
                                            <th>日期</th>
                                            <th>注册用户数</th>
                                            <th>登陆用户数</th>
                                            <th>发主贴用户数</th>
                                            <th>发回复用户数</th>
                                            <th>点赞用户数</th>
                                            <th>分享用户数</th>
                                        </tr>
                                    </thead>
                                    <tbody id="user_data_list">
                                    <?php
                                    $j_addNumTotal=0;$j_loginNumTotal=0;$j_postNumTotal=0;$j_replyNumTotal=0;$j_likeNumTotal=0;$j_shareNumTotal=0;
                                    $z_addNumTotal=0;$z_loginNumTotal=0;$z_postNumTotal=0;$z_replyNumTotal=0;$z_likeNumTotal=0;$z_shareNumTotal=0;
                                    for($i=0; $i>=-7; $i--){
                                        $time = strtotime($i." days", time());
                                        $day = date("Y-m-d", $time);
                                        $startTime = strtotime($day." 00:00:00");
                                        $endTime = strtotime($day." 23:59:59");

                                        $j_addNum = $this->IndexModel->tongjiUserNum($startTime, $endTime, 1, 1);
                                        $j_addNumTotal += $j_addNum;

                                        $z_addNum = $this->IndexModel->tongjiUserNum($startTime, $endTime, 1, 2);
                                        $z_addNumTotal += $z_addNum;

                                        $j_loginNum  = $this->IndexModel->tongjiUserNum($startTime, $endTime, 2, 1);
                                        $j_loginNumTotal+=$j_loginNum;

                                        $z_loginNum  = $this->IndexModel->tongjiUserNum($startTime, $endTime, 2, 2);
                                        $z_loginNumTotal+=$z_loginNum;

                                        $j_postNum = $this->IndexModel->tongjiUserNum($startTime, $endTime, 3, 1);
                                        $j_postNumTotal+=$j_postNum;

                                        $z_postNum = $this->IndexModel->tongjiUserNum($startTime, $endTime, 3, 2);
                                        $z_postNumTotal+=$z_postNum;

                                        $j_replyNum  = $this->IndexModel->tongjiUserNum($startTime, $endTime, 4, 1);
                                        $j_replyNumTotal+=$j_replyNum;

                                        $z_replyNum  = $this->IndexModel->tongjiUserNum($startTime, $endTime, 4, 2);
                                        $z_replyNumTotal+=$z_replyNum;

                                        $j_likeNum  = $this->IndexModel->tongjiUserNum($startTime, $endTime, 5, 1);
                                        $j_likeNumTotal+=$j_likeNum;

                                        $z_likeNum  = $this->IndexModel->tongjiUserNum($startTime, $endTime, 5, 2);
                                        $z_likeNumTotal+=$z_likeNum;

                                        $j_shareNum  = $this->IndexModel->tongjiUserNum($startTime, $endTime, 6, 1);
                                        $j_shareNumTotal+=$j_shareNum;

                                        $z_shareNum  = $this->IndexModel->tongjiUserNum($startTime, $endTime, 6, 2);
                                        $z_shareNumTotal+=$z_shareNum;
                                        ?>
                                        <tr>
                                            <td><?php echo $day;?></td>
                                            <td><?php echo "机器：".$j_addNum.";注册:".$z_addNum;?></td>
                                            <td><?php echo "机器：".$j_loginNum.";注册:".$z_loginNum;?></td>
                                            <td><?php echo "机器：".$j_postNum.";注册:".$z_postNum;?></td>
                                            <td><?php echo "机器：".$j_replyNum.";注册:".$z_replyNum;?></td>
                                            <td><?php echo "机器：".$j_likeNum.";注册:".$z_likeNum;?></td>
                                            <td><?php echo "机器：".$j_shareNum.";注册:".$z_shareNum;?></td>
                                        </tr>
                                    <?php } ?>
                                    <tr>
                                        <td>合计</td>
                                        <td><?php echo "机器：".$j_addNumTotal.";注册:".$z_addNumTotal;?></td>
                                        <td><?php echo "机器：".$j_loginNumTotal.";注册:".$z_loginNumTotal;?></td>
                                        <td><?php echo "机器：".$j_postNumTotal.";注册:".$z_postNumTotal;?></td>
                                        <td><?php echo "机器：".$j_replyNumTotal.";注册:".$z_replyNumTotal;?></td>
                                        <td><?php echo "机器：".$j_likeNumTotal.";注册:".$z_likeNumTotal;?></td>
                                        <td><?php echo "机器：".$j_shareNumTotal.";注册:".$z_shareNumTotal;?></td>
                                    </tr>
                                    </tbody>
                                </table>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<?php  include VIEWPATH.'common/footer.php';  ?>